package myThread;

import java.util.Scanner;

public class demo24 {
    public static void main(String[] args) {
        Object locker1 = new Object();
        Object locker2 = new Object();
        Thread t1 = new Thread(()->{
           try{
               System.out.println("wait之前");
               synchronized (locker1){
                   locker1.wait();
               }
               System.out.println("wait之后");
           }catch (InterruptedException e){
               throw new RuntimeException();
           }
        });
        Thread t2 = new Thread(()->{
           Scanner scanner = new Scanner(System.in);
            System.out.println("输入任意内容唤醒 t1");
            scanner.next();
            synchronized (locker1){
                locker1.notify();
            }
        });
        t1.start();
        t2.start();
    }
}
